//
// Created by cube on 2020/10/24.
//

#ifndef COMPILERDOMEA1_UDPPOOL_H
#define COMPILERDOMEA1_UDPPOOL_H


#include <map>

#include "../lib/Platform/NetBase.h"
#include "../lib/Platform/Multplex.h"
#include "Option.h"
#include "../lib/Container/ThreadContainer.h"
#include "../lib/Base/AOP_IOC.h"

using namespace NetBase;

class UdpPool : public Multplex{
public:
    UdpPool(int count): Multplex(count),__send_udp_index(0){}

    int send(const NetAddress& addr,int8_t* data,const uint32_t& len);
    void bind(const NetAddress& addr);
    void ubind(const NetAddress& addr);
    void close();

protected:
    bool read(int socket) override ;
    virtual int read_from_io(NetUdp& udp,NetAddress& addr){ return 0;}
    NetUdp& udp_socket();

private:
    TMap<NetAddress,int> __udps;
    std::atomic_uint64_t    __send_udp_index;
};


#endif //COMPILERDOMEA1_UDPPOOL_H
